package com.game77.guessTheWords2.sprite;

import android.graphics.Typeface;
import android.util.Log;

import com.game77.guessTheWords2.R;
import com.game77.guessTheWords2.layer.GameLayer;
import com.game77.guessTheWords2.util.AudioHelper;
import com.wiyun.engine.nodes.Button;
import com.wiyun.engine.nodes.Label;
import com.wiyun.engine.nodes.Node;
import com.wiyun.engine.types.WYColor3B;

public class KeyItemBlock extends Node {

	Button keyButton;
	Label keyLabel;

	String myKeyString;

	public KeyItemBlock(String keyString) {
		keyButton = Button.make(R.drawable.word_button_normal,
				R.drawable.word_button_pressed, this, "onKeyClicked");
		keyButton.setPosition(0, 0);
		this.addChild(keyButton);

		keyLabel = Label.make(keyString, 25, Typeface.BOLD);
		keyLabel.setColor(WYColor3B.make(20, 20, 20));
		keyLabel.setPosition(0, 0);
		keyLabel.setEnabled(false);
		this.addChild(keyLabel);

		myKeyString = keyString;

		if (keyString.equals("")) {
			keyLabel.setVisible(false);
			keyButton.setEnabled(false);
		}
	}

	public void onKeyClicked() {
		Log.d("click", myKeyString);
		AudioHelper.keyboard();
		GameLayer.instance.touchKey(myKeyString);
	}
}
